﻿#region Using directives
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;
#endregion

namespace gpsMe.Utils
{
    /// <summary>
    /// Instanciated at the launch of the software to perform fastidious tasks only one time and to keep their results into ram
    /// </summary>
    public class gpsMeOptimizer
    {
        #region Instance
        /// <summary>
        /// Current gpsMeOptimizer instance
        /// </summary>
        public static gpsMeOptimizer Instance { get; private set; }
        #endregion

        #region Accessors
        /// <summary>
        /// ArrayList of every maps present in the file system
        /// </summary>
        public ArrayList MapsInFileSystem { get; private set; }

        /// <summary>
        /// ArrayList of evey languages present in the file system
        /// </summary>
        public ArrayList LanguagesInFileSystem { get; private set; }
        #endregion

        #region Constructor
        /// <summary>
        /// Defaut constructor for gpsMeOptimizer
        /// </summary>
        public gpsMeOptimizer()
        {
            Instance = this;
            this.FindAllMapsFromsFileSystem();
            this.FindAllLanguagesInFileSystem();
        }
        #endregion

        #region Functions / Methoods / Events
        /// <summary>
        /// Launches the map research procedure
        /// </summary>
        private void FindAllMapsFromsFileSystem()
        {
            this.MapsInFileSystem = gpsMeUtils.FindAllFilesFromExtension(@"\", new TreeNode(), ".map.xml", new ArrayList());
        }

        /// <summary>
        /// Launches the Languages research procedure
        /// </summary>
        private void FindAllLanguagesInFileSystem()
        {
            this.LanguagesInFileSystem = gpsMeUtils.FindAllFilesFromExtension( gpsMeUtils.ApplicationDirectory, new TreeNode(), ".language.xml", new ArrayList());
        }
        #endregion
    }
}
